var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32882675-1']);
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = 'https://ssl.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

function key_pressed(ev) {
	document.getElementById("pressed_key").value = ""+ev.keyCode;
}

function key_pressed(ev) {
	gridder.key(ev.keyCode);
};
window.onload = function() {
	var supplied_grid_type = "random";
	var supplied_grid = 1;

	var p = window.location.href.indexOf("grid.html?p=");
	if (-1!=p) {
		supplied_grid_type = "data";
		supplied_grid = window.location.href.substr(p+12);
	} else {
		var p = window.location.href.indexOf("grid.html?r=");
		if (-1!=p) {
			supplied_grid = 1*window.location.href.substr(p+12);
		}
	}

	gridder.doc = document;
	gridder.init_gecko();
	gridder.init_chromium_ext();
	gridder.init();
	if ("data"==supplied_grid_type) {
		gridder.start_grid(supplied_grid);
	} else {
		gridder.generate(supplied_grid);
	}

    document.body.addEventListener("contextmenu", function() {return false;});
    document.body.addEventListener("keyup", key_pressed);
};
window.onunload = function() {
	gridder.smart_save();
};

// Place this render call where appropriate
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();


